/**
 * 
 */
package com.hand.cloud.b2b.daos.impl;

import de.hybris.platform.core.model.order.OrderModel;
import de.hybris.platform.servicelayer.exceptions.ModelSavingException;
import de.hybris.platform.servicelayer.model.ModelService;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hand.cloud.b2b.daos.EPLogisticsDAO;
import com.hand.cloud.b2b.model.EPLogisticsModel;


/**
 * @author Snowling
 * @time 2014-8-26 下午1:21:07
 * 
 */
@Component(value = "epLogisticsDAO")
public class DefaultEPLogisticDAO implements EPLogisticsDAO
{

	public static Logger LOG = Logger.getLogger(DefaultEPLogisticDAO.class);

	@Autowired
	private ModelService modelService;

	/**
	 * 创建已完成的订单的物流信息
	 */
	@Override
	public EPLogisticsModel createEPLogistics(OrderModel order)
	{
		EPLogisticsModel epLogisticsModel = modelService.create(EPLogisticsModel.class);
		epLogisticsModel.setOrder(order);
		epLogisticsModel.setTid(192390290386705L);
		epLogisticsModel.setOutSid("210283341631");
		epLogisticsModel.setCompanyCode("HTKY");

		try
		{
			this.modelService.save(epLogisticsModel);
		}
		catch (ModelSavingException e)
		{
			LOG.info("---------createEPLogistics error-----------");
			e.printStackTrace();
			return null;
		}
		return epLogisticsModel;
	}

}
